package clazz.innerclazz;

import org.junit.Test;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Description：
 * @Author：LiDong
 * @Create：2020/12/21
 * @Version：1.0.0
 */
public class InnerClazzTest {

    private static final Logger logger = LoggerFactory.getLogger(InnerClazzTest.class);


    @Test
    public void test1() {
        OutClass outClass1 = new OutClass();
        // innerClazz1是outClass对象的对象
        OutClass.MyInnerClazz innerClazz1 = outClass1.new MyInnerClazz();
        innerClazz1.setInnerId(1);
        outClass1.setOutId(1);
        outClass1.setInnerClazz(innerClazz1);
        logger.info(outClass1.toString());


        OutClass outClass2 = new OutClass();
        // innserClazz2相当于new OutClass的对象
        OutClass.MyInnerClazz innerClazz2 = new OutClass().new MyInnerClazz();
        outClass2.setOutId(2);
        innerClazz2.setInnerId(2);
        outClass2.setInnerClazz(innerClazz2);
        logger.info(outClass2.toString());


    }

}
